/**
 * 
 */

package CCT220_Aula12_Exercicio01_13106.info.academico.disciplina;


import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;

import javax.swing.JOptionPane;


/**
 * ******************************
 * Project: CCT220
 * Package: CCT220_Aula12_Exercicio01_13106.info.academico.disciplina
 * Class: VetorDisciplina
 * Last Change: 27/09/2011 15:52:44
 * Description:
 * ******************************
 * 
 * @author marcel
 * @author 13106
 * 
 */
public class VetorDisciplina {

	private final Vector<Disciplina> v;


	/**
	 * ******************************
	 * Constructor for
	 * Package: CCT220_Aula12_Exercicio01_13106.info.academico.disciplina
	 * Class: VetorDisciplina
	 * LastChange: 27/09/2011 15:53:34
	 * ******************************
	 * 
	 * @param v
	 */
	public VetorDisciplina() {

		super();
		this.v = new Vector<Disciplina>();
	}


	/**
	 * ******************************
	 * Package: CCT220_Aula12_Exercicio01_13106.info.academico.disciplina
	 * Class: VetorDisciplina
	 * Method: addDisciplina
	 * Last Change: 27/09/2011 15:55:15
	 * Description:
	 * ******************************
	 * 
	 * @param disciplina
	 */
	public void addDisciplina(Disciplina disciplina) {

		this.v.addElement(disciplina);
	}


	/**
	 * ******************************
	 * Package: CCT220_Aula12_Exercicio01_13106.info.academico.disciplina
	 * Class: VetorDisciplina
	 * Method: removeDisciplina
	 * Last Change: 27/09/2011 15:55:19
	 * Description:
	 * ******************************
	 * 
	 * @param disciplina
	 */
	public void removeDisciplina(Disciplina disciplina) {

		for (int i = 0; i < v.size(); i++) {
			if (v.get(i).equals(disciplina)) {
				JOptionPane.showMessageDialog(null, "Removendo "
				        + v.elementAt(i), "Remocao", JOptionPane.ERROR_MESSAGE);
				v.removeElementAt(i);
			}
		}
	}


	/**
	 * ******************************
	 * Package: CCT220_Aula12_Exercicio01_13106.info.academico.disciplina
	 * Class: VetorDisciplina
	 * Method: removeDisciplina
	 * Last Change: 27/09/2011 15:55:22
	 * Description:
	 * ******************************
	 * 
	 * @param codigo
	 */
	public void removeDisciplina(int codigo) {

		for (int i = 0; i < v.size(); i++) {
			if (v.get(i).equals(new Disciplina(codigo, "", 0))) {
				JOptionPane.showMessageDialog(null, "Removendo "
				        + v.elementAt(i), "Remocao", JOptionPane.ERROR_MESSAGE);
				v.removeElementAt(i);
			}
		}
	}


	/**
	 * ******************************
	 * Package: CCT220_Aula12_Exercicio01_13106.info.academico.disciplina
	 * Class: VetorDisciplina
	 * Method: imprimeDisciplinas
	 * Last Change: 27/09/2011 16:22:39
	 * Description:
	 * ******************************
	 * 
	 * @return A list
	 */
	public List<String> imprimeDisciplinas() {

		List<String> list = new LinkedList<String>();

		Iterator<Disciplina> it = v.iterator();
		while (it.hasNext()) {
			list.add(it.next().toString());

		}

		return list;
	}

}
